package hidra.io;



import hidra.core.util.Configuration;
import hidra.jmetal.core.SolutionSet;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class VariablesWriter {

	private SolutionSet solutionSet;
	
	public VariablesWriter(SolutionSet solutionSet) {
		this.solutionSet = solutionSet;
	}
	
	public void printVariablesToFile(String path){
	    try {
	      /* Open the file */
	      FileOutputStream fos   = new FileOutputStream(path)     ;
	      OutputStreamWriter osw = new OutputStreamWriter(fos)    ;
	      BufferedWriter bw      = new BufferedWriter(osw)        ;            
	            
	      int numberOfVariables = solutionSet.get(0).numberOfVariables() ;
	      for (int i = 0; i < solutionSet.size(); i++) {  
	      	for (int j = 0; j < numberOfVariables; j++)
	         // bw.write(solutionSet.get(i).getDecisionVariables().ge(j) + " ");
	        bw.newLine();        
	      }
	      
	      /* Close the file */
	      bw.close();
	    }catch (IOException e) {
	      Configuration.logger.severe("Error acceding to the file");
	      e.printStackTrace();
	    }       
	  }
	
}
